﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OfficeOpenXml;

namespace Kanban.Common
{
    public class ExcelHelper
    {
        public static ExcelWorksheet Read(string path)
        {
            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            using (ExcelPackage package = new ExcelPackage(path))
            {
                ExcelWorksheet wb = package.Workbook.Worksheets[0];
                //for (int i = 1; i <= wb.Dimension.Rows; i++)
                //{
                //    string ip = wb.Cells[i, 1].Value.ToString();
                //}
                package.Save();
                return wb;
            }
        }

        public static ExcelWorksheet Read(FileInfo file)
        {
            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            using (ExcelPackage package = new ExcelPackage(file))
            {
                ExcelWorksheet wb = package.Workbook.Worksheets[0];
                package.Save();
                return wb;
            }
        }

        public static ExcelWorksheet Read(Stream stream)
        {
            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            using (ExcelPackage package = new ExcelPackage(stream))
            {
                ExcelWorksheet wb = package.Workbook.Worksheets[0];
                package.Save();
                return wb;
            }
        }

    }
}
